class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2025-08-27",
      revision: "e7d763e7175e848fcee79fde3621975a8db859d3"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_sequoia: "e5a1e1947b530d7a35bdc3fd96ce0b9b83a29aea9799405dc22aed8bf9465ce7"
    sha256 cellar: :any_skip_relocation, arm64_sonoma:  "cfb23dfb066aeee71a38638fa1f3d81f422a36d96b43b7b21a498a538b93ba4b"
    sha256 cellar: :any_skip_relocation, arm64_ventura: "dbbcf126236cb0c20529386f61fca0eaff852ea3272df63103f8eb63e929cf7d"
    sha256 cellar: :any_skip_relocation, sonoma:        "6a9ac73d9a456ae4a91b46f710982a3be1f1c4d6254b6ca407a50cfccc2e0305"
    sha256 cellar: :any_skip_relocation, ventura:       "e7431d8c5d0d448a1c750e451738ec928fd1f7bfc7b5f1d7063e73a7990022cf"
    sha256 cellar: :any_skip_relocation, arm64_linux:   "7a4dccf315235d54ec572e75efa291bacfead9dd3cb0f1504d49f80e81dcd833"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "9546ebc072212626aa9ee3ab4e00e8a0f7b1b1c5734d7c2dd6a9de476b9f80f6"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system bin/"searchsploit", "sendpage"
  end
end
